/***************************************************************************
 *   Copyright (C) 2007 by Sebastian Bilski, Lance Cooper, Jeff Rebacz,
 *   									and Alex Zelenskiy
 *   sbilski@iit.edu
 *   lance.m.cooper@gmail.com
 *   jeff.rebacz@gmail.com
 *   voiceofanarchy@gmail.com
 *
 *	This file is part of connect3
 *
 *   connect3 is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License, version 2,
 *    as published by the Free Software Foundation
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program; if not, write to the
 *   Free Software Foundation, Inc., 
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. 
 ***************************************************************************/

import java.awt.Color;

import junit.framework.TestCase;


public class Test_Player extends TestCase {
	
	Player ply1;
	Player ply2;
	Player ply3;
	
	public Test_Player(String name){
		super(name);
	}	
	
	protected void setUp(){
		ply1 = new Player();
		ply2 = new Player("Kirk", Color.BLACK);
		ply3 = new Player("",null);
	}
	
	protected void tearDown(){
	}
	
	public void testDefaultConstructor(){
		assertTrue(ply1.getColor() == Color.RED);
		assertTrue(ply1.getPieces() !=null);
		assertFalse(ply1.isReadyToStart());
		assertTrue(ply1.getTurnOrder()==0);
	}
	
	public void testNonDefaultConstructor(){
		assertTrue(ply2.getColor().equals(Color.BLACK));
		assertTrue(ply2.getUserName().equals("Kirk"));
		assertFalse(ply2.isReadyToStart());
		assertTrue(ply2.getTurnOrder()==0);
	}
	
	public void testBadInputToConstructor(){
		assertTrue(ply3.getColor()==null);
		assertTrue(ply3.getUserName().equals(""));
		assertFalse(ply3.isReadyToStart());
		assertTrue(ply3.getTurnOrder()==0);
	}
	
	public void testSetters(){
		ply1.setColor(Color.BLUE);
		ply1.setReadyToStart(true);
		ply1.setTurnOrder(10);
		ply1.setUserName("jo");
		
		assertTrue(ply1.getColor().equals(Color.BLUE));
		assertTrue(ply1.getUserName().equals("jo"));
		assertTrue(ply1.isReadyToStart());
		assertTrue(ply1.getTurnOrder()==10);
		
		ply1.setReadyToStart(false);
		assertFalse(ply1.isReadyToStart());
		
		ply1.setTurnOrder(0);
		assertTrue(ply1.getTurnOrder()==0);
		
		ply1.setTurnOrder(4);
		ply1.setTurnOrder(-123);
		assertTrue(ply1.getTurnOrder()==4);
	}
	
	public void testPlayerArray(){
		GamePiece gp = ply2.generatePiece();
		assertTrue(gp.getP()==ply2);
		assertTrue(gp.getColor().equals(ply2.getColor()));
		gp.setX(5);
		gp.setY(3);
		ply2.addPiece(gp);
		GamePiece gp2 = new GamePiece(5, 6, Color.RED);
		GamePiece gp3 = new GamePiece(12345, 4, Color.WHITE);
		GamePiece gp4 = new GamePiece(-1234, 4, Color.BLACK);
		GamePiece gp5 = new GamePiece(0,0,null);
		GamePiece gp6 = new GamePiece(-31, -4312, Color.BLUE);
		ply2.addPiece(gp2);
		ply2.addPiece(gp3);
		ply2.addPiece(gp4);
		ply2.addPiece(gp5);
		ply2.addPiece(gp6);
		
		assertTrue(ply2.getPieces().size()==7);
		assertTrue(ply2.getPieces().get(0)==gp);
		assertTrue(ply2.getPieces().get(1)==gp);
		assertTrue(ply2.getPieces().get(2)==gp2);
		assertTrue(ply2.getPieces().get(3)==gp3);
		assertTrue(ply2.getPieces().get(4)==gp4);
		assertTrue(ply2.getPieces().get(5)==gp5);
		assertTrue(ply2.getPieces().get(6)==gp6);
		
		
	}
}
